package com.travelshare.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.travelshare.common.annotation.Log;
import com.travelshare.common.core.controller.BaseController;
import com.travelshare.common.core.domain.AjaxResult;
import com.travelshare.common.enums.BusinessType;
import com.travelshare.business.domain.InfoSensitive;
import com.travelshare.business.service.IInfoSensitiveService;
import com.travelshare.common.utils.poi.ExcelUtil;
import com.travelshare.common.core.page.TableDataInfo;

/**
 * 敏感词信息Controller
 * 
 * @author travelshare
 * @date 2024-02-22
 */
@RestController
@RequestMapping("/business/infoSensitive")
public class InfoSensitiveController extends BaseController
{
    @Autowired
    private IInfoSensitiveService infoSensitiveService;

    /**
     * 查询敏感词信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:infoSensitive:list')")
    @GetMapping("/list")
    public TableDataInfo list(InfoSensitive infoSensitive)
    {
        startPage();
        List<InfoSensitive> list = infoSensitiveService.selectInfoSensitiveList(infoSensitive);
        return getDataTable(list);
    }

    /**
     * 导出敏感词信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:infoSensitive:export')")
    @Log(title = "敏感词信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfoSensitive infoSensitive)
    {
        List<InfoSensitive> list = infoSensitiveService.selectInfoSensitiveList(infoSensitive);
        ExcelUtil<InfoSensitive> util = new ExcelUtil<InfoSensitive>(InfoSensitive.class);
        util.exportExcel(response, list, "敏感词信息数据");
    }

    /**
     * 获取敏感词信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:infoSensitive:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(infoSensitiveService.selectInfoSensitiveById(id));
    }

    /**
     * 新增敏感词信息
     */
    @PreAuthorize("@ss.hasPermi('business:infoSensitive:add')")
    @Log(title = "敏感词信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InfoSensitive infoSensitive)
    {
        return toAjax(infoSensitiveService.insertInfoSensitive(infoSensitive));
    }

    /**
     * 修改敏感词信息
     */
    @PreAuthorize("@ss.hasPermi('business:infoSensitive:edit')")
    @Log(title = "敏感词信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InfoSensitive infoSensitive)
    {
        return toAjax(infoSensitiveService.updateInfoSensitive(infoSensitive));
    }

    /**
     * 删除敏感词信息
     */
    @PreAuthorize("@ss.hasPermi('business:infoSensitive:remove')")
    @Log(title = "敏感词信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(infoSensitiveService.deleteInfoSensitiveByIds(ids));
    }
}
